package com.lagou.mr.homework;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

//将文件中的数字转换为LongWritable类型，作为map阶段的key输出
public class wordOrderMapper extends Mapper<LongWritable, Text, LongWritable, NullWritable> {

    LongWritable number= new LongWritable();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //读取每一行文本
        String str = value.toString();

        //LongWritable接收每一行数据
        number =new LongWritable(Long.parseLong(str));

        //每一个行数据作为map阶段key输出
        context.write(number,NullWritable.get());



    }
}
